Imports Microsoft.VisualBasic
Imports com.amazon.webservices
Imports sk.DAL

Public Class ProductObj
    Inherits BizObject


    Sub New(ByVal ASIN As String, ByVal Title As String, ByVal Description As String, ByVal ListPrice As String, ByVal Price As String, ByVal Savings As Double, ByVal Rating As Integer, ByVal Category As Integer, ByVal ImageURL As String)
        ' These are pulled from the database
        _ASIN = ASIN
        _Title = Title
        _Description = Description
        _CategoryID = Category


        ' These are pulled from Amazon
        _ImageURL = ImageURL
        _ListPrice = ListPrice
        _Price = Price
        _Savings = Savings
        _Rating = Rating


    End Sub

    Sub New()

    End Sub

    Private _ASIN As String
    Public Property ASIN() As String
        Get
            Return _ASIN
        End Get
        Set(ByVal value As String)
            _ASIN = value
        End Set
    End Property



    Private _Title As String
    Public Property Title() As String
        Get
            Return _Title
        End Get
        Set(ByVal value As String)
            _Title = value
        End Set
    End Property

    Private _ImageURL As String
    Public Property ImageURL() As String
        Get
            Return _ImageURL
        End Get
        Set(ByVal value As String)
            _ImageURL = value
        End Set
    End Property


    Private _Description As String
    Public Property Description() As String
        Get
            Return _Description
        End Get
        Set(ByVal value As String)
            _Description = value
        End Set
    End Property

    Private _ListPrice As String
    Public Property ListPrice() As String
        Get
            Return _ListPrice
        End Get
        Set(ByVal value As String)
            _ListPrice = value
        End Set
    End Property

    Private _Price As String
    Public Property Price() As String
        Get
            Return _Price
        End Get
        Set(ByVal value As String)
            _Price = value
        End Set
    End Property

    Private _Savings As Double
    Public Property Savings() As Double
        Get
            Return _Savings
        End Get
        Set(ByVal value As Double)
            _Savings = value
        End Set
    End Property

    Private _Rating As Integer
    Public Property Rating() As Integer
        Get
            Return _Rating
        End Get
        Set(ByVal value As Integer)
            _Rating = value
        End Set
    End Property

    Private _CategoryID As Integer
    Public Property CategoryID() As Integer
        Get
            Return _CategoryID
        End Get
        Set(ByVal value As Integer)
            _CategoryID = value
        End Set
    End Property

    Public Function GetProductByID(ByVal ProductID As String) As ProductObj
        Try

            Dim provider As ProductProvider
            provider = ProductProvider.Instance
            Dim obj As New ProductObj

            Dim product As Product = provider.GetProductByID(ProductID)

            obj.ASIN = product.ASIN
            obj.CategoryID = product.CategoryID
            obj.Description = product.Description
            obj.ImageURL = product.ImageURL
            obj.ListPrice = product.ListPrice
            obj.Price = product.Price
            obj.Title = product.Title

            Return obj

        Catch ex As Exception
            Return New ProductObj
        End Try
    End Function

End Class
